package tools;

import java.io.File;
import java.io.IOException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.opera.OperaDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;

public class webdriver_do {

	public WebDriver wd;
	
	

	@Test
		public void init_webdriver() throws IOException {
			
	
			/*String driverPath=new File("./").getCanonicalPath()+"/src/test/java/driver/chromedriver.exe";
			String driverName="webdriver.chrome.driver";*/
			
		
		

		//String driverPath=new File("./").getCanonicalPath()+"/src/test/java/driver/operadriver.exe";

		String driverPath=new File("./").getCanonicalPath()+"/src/test/java/driver/chromedriver.exe";



		//String driverName="webdriver.opera.driver";
		String driverName="webdriver.chrome.driver";

		System.setProperty(driverName, driverPath);

			/*wd=new ChromeDriver();*/

		wd = new RemoteWebDriver(new URL("http://192.168.1.10:4444/wd/hub/"), DesiredCapabilities.chrome());
			//wd=new ChromeDriver();
			
			wd.manage().window().maximize();
			
			wd.get("https://testerhome.com");
			
			System.err.println("-----webdriver初始化完毕！！！----\n");
		
			}

	//判断元素是否存在
	
		public static boolean isPresentEle(By by, webdriver_do wd) {
			try {
				((WebDriver) wd).findElement(by);
				return true;
			} catch (Exception e) {
				return false;
			}
		}

	}
		
	
	

	
